#ifndef __X_IMAGE_H__
#define __X_IMAGE_H__

#include "xobject.h"
#include "xplatformmacros.h"

class xImage : public xObject
{
public:
    xImage();
    ~xImage();

    typedef enum
    {
        kFmtJpg = 0,
        kFmtPng,
        kFmtRawData,
        kFmtUnknow
    } EImageFormat;

    typedef enum
    {
        kAlignCenter        = 0x33,         // Horizontal center and vertical center
        kAlignTop           = 0x13,         // Horizontal center and vertical top
        kAlignTopRight      = 0x12,         // Horizontal right and vertical top
        kAlignRight         = 0x32,         // Horizontal right and vertical center
        kAlignBottomRight   = 0x22,         // Horizontal right and vertical bottom
        kAlignBottom        = 0x23,         // Horizontal center and vertical bottom
        kAlignBottomLeft    = 0x21,         // Horizontal left and vertical bottom
        kAlignLeft          = 0x31,         // Horizontal left and vertical center
        kAlignTopLeft       = 0x11,         // Horizontal left and vertical top
    } ETextAlign;

    bool initWithImageFile(const char *path, EImageFormat imageType = kFmtPng);

    // Members
    X_SYNTHESIZE_READONLY(unsigned short, _width, Width);
    X_SYNTHESIZE_READONLY(unsigned short, _height, Height);
    X_SYNTHESIZE_READONLY(int, _bitsPerComponent, BitsPerComponent);

protected:
    bool _initWithPngData(void *data, int dataLength);

    unsigned char *_data;
    bool _hasAlpha;
    bool _preMulti;

private:
    // uncopyable
    xImage(const xImage &);
    xImage &operator=(const xImage &);
};

#endif // __X_IMAGE_H__